
char fsm[9][128];
void initfsm()
{
	const int line_len=sizeof(char)*128;
	memset(fsm[0],0,line_len);
	memset(fsm[1],0,line_len);
	memset(fsm[2],2,line_len);
	memset(fsm[3],3,line_len);
	memset(fsm[4],3,line_len);
	memset(fsm[5],5,line_len);
	memset(fsm[6],5,line_len);
	memset(fsm[7],0,line_len);
	memset(fsm[8],0,line_len);
	fsm[0]['/']=1;
	fsm[0]['"']=5;
	fsm[0]['\\']=8;
	fsm[1]['/']=2;
	fsm[1]['*']=3;
	fsm[1]['"']=5;
	fsm[2]['\n']=7;
	fsm[3]['*']=4;
	fsm[4]['/']=7;
	fsm[4]['*']=4;
	fsm[5]['"']=0;
	fsm[5]['\\']=6;
	fsm[7]['/']=1;
	fsm[7]['"']=5;
	fsm[7]['\\']=8;
}

void deleteComment()
{
	int state=0;
	char c;
	std::string s;
	FILE *fin=fopen("/users/rui/desktop/in.txt","r");
	FILE *fout=fopen("/users/rui/desktop/out.txt","w");
	initfsm();
	while(fscanf(fin,"%c",&c)!=EOF)
	{
		state=fsm[state][c];
		s+=c;
		switch(state)
		{
			case 0:
				fprintf(fout,"%s",s.c_str());
				s="";
				break;
			case 7:
				s="";
				if(c=='\n')
				{
					fputc(c,fout);
				}
				break;
		}
	}
	fclose(fin);
	fclose(fout);
}


